//
//  HZStatusView.swift
//  weibo002
//
//  Created by 黑眼圈 on 16/4/20.
//  Copyright © 2016年 heiyan. All rights reserved.
//

import UIKit

class HZStatusView: UIView {

 
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
        
            backgroundColor = UIColor.whiteColor()
        
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    // MARK: -  添加子控件
    private func setupUI(){
        
        let transpondBtn = addChildButton("转发", imgNamed: "timeline_icon_retweet")
        let commentBtn = addChildButton("评论", imgNamed: "timeline_icon_comment")
        let praiseBtn = addChildButton("赞", imgNamed: "timeline_icon_unlike")
        
        
        //约束
        transpondBtn.snp_makeConstraints { (make) -> Void in
            
            make.leading.equalTo(0)
            make.top.bottom.equalTo(self)
            make.width.equalTo(commentBtn)
        }
        
        commentBtn.snp_makeConstraints { (make) -> Void in
            
            make.leading.equalTo(transpondBtn.snp_trailing)
            make.top.bottom.equalTo(self)
            make.width.equalTo(praiseBtn)
        }
        
        praiseBtn.snp_makeConstraints { (make) -> Void in
            
            make.trailing.equalTo(0)
            make.top.bottom.equalTo(self)
            make.leading.equalTo(commentBtn.snp_trailing)
            make.width.equalTo(transpondBtn)
        }
        
        self.snp_makeConstraints { (make) -> Void in
            
            make.bottom.equalTo(praiseBtn.snp_bottom)
        }
        
        
    }
    
    
    private func addChildButton(title: String, imgNamed: String) -> UIButton {
        // 添加三个按钮
        let button = UIButton()
        button.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        button.titleLabel?.font = UIFont.systemFontOfSize(HZNameTextFont)
        
        button.setTitle(title, forState: UIControlState.Normal)
        // 设置显示的图片
        button.setImage(UIImage(named: imgNamed), forState: UIControlState.Normal)
        // 设置不同状态的下的背景图片
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: UIControlState.Highlighted)
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState: UIControlState.Normal)
        addSubview(button)
        
        return button
    }

}
